home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 1997
/
MacHack 1997.toast
/
Hacks
/
Hacks ’95
/
What's On My Mac
/
cgi.h
< prev
next >
Wrap
C/C++ Source or Header
|
1995-06-24
|
4KB
|
139 lines
#pragma once
/*****
*
* Grant's CGI Shell (Common Grant Interface :-)
*
* cgi.h
*
* standard types and functions for cgi applications
*
* by Grant Neufeld
* http://arpp1.carleton.ca/grant/
* gneufeld@ccs.carleton.ca
* grant@acm.org
*
* Copyright ©1995 by Grant Neufeld
*
* This source may be freely used as long as the copyright notice is kept in the source.
* I (we) ask that you let us know of any enhancements (read: bug fixes) to this code.
* I (we) would also like copies of (or discounts on) anything you produce this with, please.
*
*****/
/*** CONSTANT DECLARATIONS ***/
#define kCGIParamMaxSize 32767
#define kCGIHTTPMethodGet "GET"
#define kCGIHTTPMethodPost "POST"
#define kCGIFormFieldDelimiter '='
#define kCGIFormFieldSeparator '&'
#define kCGIpath_args '----'
#define kCGIhttp_search_args 'kfor'
#define kCGIusername 'user'
#define kCGIpassword 'pass'
#define kCGIfrom_user 'frmu'
#define kCGIclient_address 'addr'
#define kCGIpost_args 'post'
#define kCGImethod 'meth'
#define kCGIserver_name 'svnm'
#define kCGIserver_port 'svpt'
#define kCGIscript_name 'scnm'
#define kCGIcontent_type 'ctyp'
#define kCGIreferer 'refr'
#define kCGIuser_agent 'Agnt'
#define kCGIaction 'Kact'
#define kCGIaction_path 'Kapt'
#define kCGIclient_ip 'Kcip'
#define kCGIfull_request 'Kfrq'
/*** TYPE DECLARATIONS ***/
typedef struct
{
char * name;
char * value;
} CGIFormField;
typedef enum
{
HTTP_UNDEFINED,
HTTP_get,
HTTP_post
} HTTPMethod;
typedef struct
{
char * path_args; /* '----' path_args */
char * http_search_args; /* 'kfor' http_search_args */
char * username; /* 'user' username */
char * password; /* 'pass' password */
char * from_user; /* 'frmu' from_user */
char * client_address; /* 'addr' client_address */
char * post_args; /* 'post' post_args */
HTTPMethod method; /* 'meth' method */
char * server_name; /* 'svnm' server_name */
short server_port; /* 'svpt' server_port */
char * script_name; /* 'scnm' script_name */
char * content_type; /* 'ctyp' content_type */
char * referer; /* 'refr' referer */
char * user_agent; /* 'Agnt' user_agent */
char * action; /* 'Kact' action */
char * action_path; /* 'Kapt' action_path */
char * client_ip; /* 'Kcip' client_ip */
char * full_request; /* 'Kfrq' full_request */
CGIFormField * formFields; /* the fields from form submission */
long totalFields; /* total number of fields */
char * responseData; /* the data to be returned */
long responseSize; /* the size of the response */
AppleEvent * appleEvent; /* originating appleEvent */
AppleEvent * replyEvent; /* apple event reply record */
} CGIrecord;
typedef CGIrecord ** CGIHdl;
/*** GLOBAL DECLARATIONS ***/
#ifdef __MainSegment__
#define _GLOBAL_
#else
#define _GLOBAL_ extern
#endif
_GLOBAL_ Str255 gHTTPHeaderOK;
_GLOBAL_ Str255 gHTTPHeaderRedirect;
_GLOBAL_ Str255 gHTTPHeaderErr;
_GLOBAL_ long gHTTPHeaderOKSize;
_GLOBAL_ long gHTTPHeaderRedirectSize;
_GLOBAL_ long gHTTPHeaderErrSize;
#undef _GLOBAL_
/*** FUNCTION PROTOTYPES ***/
void InitCGIUtil ( void );
void CGIDisposeHandle ( CGIHdl );
CGIFormField * CGIFormFieldsFromArgs ( char *, long * );
CGIFormField * CGIFormFieldsFindRecord ( CGIFormField *, char * );
void CGIFormFieldsDispose ( CGIFormField * );
void CGIDecodeSpecialChars ( char * );
char * CGIEncodeSpecialChars ( char * );
void CGICharToHex ( unsigned char, char * );
pascal OSErr CGIAEHandle ( AppleEvent *, AppleEvent *, long );
/*** EOF ***/